package com.example.demo.web.controller;


import com.example.demo.bean.BaseUser;
import com.example.demo.service.IBaseUserService;
import com.example.demo.utils.Message;
import com.example.demo.utils.MessageUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@Controller

@Validated
@RestController
@RequestMapping("/baseUser")
public class BaseUserController {

    @Autowired
    private IBaseUserService baseUserService;

    @GetMapping("query")
    public Message query(String username, String gender) {return MessageUtil.success(baseUserService.query(username,gender)) ;}

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BaseUser baseUser){return MessageUtil.success(baseUserService.saveOrUpdate(baseUser));}

    @DeleteMapping("deleteById")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "BaseUserId", required = true, paramType = "query")
    })
    public Message deleteById(Long id){
       baseUserService.deleteById(id);
       return MessageUtil.success("删除成功");
    }
}
